Repository navigation
fix(webvtt): keep the line break after a span end tag - #1029
Conversation
|
✅ DCO Check Passed Thanks @Arsh624, all your commits are properly signed off. 🎉 |
Merge Protections🟢 All 2 merge protections satisfied — ready to merge. Show 2 satisfied protections🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 Require two reviewer for test updatesWhen test data is updated, we require two reviewers
|
AI triage (advisory)Checked commit Warning The AI analysis did not finish. Only the deterministic checks are shown. CI safety: not assessed. Possibly related pull requests
The |
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at 1bda04a378. It read the code and did not run it.
I found no defect in the change. _add_text in docling_core/types/doc/webvtt.py sets a line feed on the span that just closed. Before the change, _create_text_components dropped that line break. I checked the edge cases: an ignored end tag, text after a start tag, and a close inside <ruby>. The change is correct in each one.
A maintainer makes the merge decision. This review never approves the pull request.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
When a cue line ended with an end tag, the text after the tag started with the line break and an empty first line. `_create_text_components` skips empty lines, so the line terminator was lost and the next line was joined to the span: `<i>a</i>` and `b` on two lines became `<i>a</i>b`. Put that terminator on the span that just closed, which is where the model keeps a line break that follows a component. Signed-off-by: Arsh624 <architshukla546@gmail.com>
1bda04a to
b3eb29b
Compare
ceberam
left a comment
There was a problem hiding this comment.
Thanks for the PR, @Arsh624, and for the clear issue write-up. I have only a couple of minor, non-blocking suggestions.
- Consider adding one case with a nested or ruby span (e.g.
<ruby>a<rt>b</rt></ruby>\nc) to the parametrization, and one where the break follows a stray end tag. It would document that the helper works for every end-tag path, not only the three simple ones. - The PR description says the rest of the suite gives the same results with and without the change. That matches what I saw, so no change is needed, but you could trim the "Tests" section to the behavior covered and leave out the tool outputs.
Signed-off-by: Arsh624 <architshukla546@gmail.com>
|
Thanks for the review, @ceberam! I added both cases. |
When a cue line ended with an end tag,
WebVTTCueBlock.parsedropped the line break after it and joined the next line to the span:parsed as
<i>Previously on the show</i>we met the team., and docling turned it into*Previously on the show*we met the team.in Markdown.The text after the end tag starts with the line break, so its first line is empty, and
_create_text_componentsskips empty lines together with their terminator.Changes
_add_text. If that text starts with a line break, the helper puts the terminator on the component right before it, which is either the span that just closed or the text before a stray end tag. That's where the model already keeps a line break that follows a component.Tests
test_webvtt_parse_line_break_after_end_tagchecks that a cue with a line break right after an end tag serializes back unchanged. It covers an italic span, two voice spans, a bold span and a ruby span with<rt>.test_webvtt_parse_line_break_after_stray_end_tagchecks that the line break after an ignored stray end tag is kept. Both fail onmainand pass with this change.Closes #1027